﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Leasson5 : MonoBehaviour
{
    public Rect barPos;
    public Rect texturePos;
    public string[] toolbars = new string[] { "强化","进化", "幻化" };
    public Texture[] textures = new Texture[3];
    private int toolbarIndex;

    private int selGridIndex;
    public Rect gridPos;
    public Rect gridTexturePos;
    private void OnGUI()
    {
        #region 知识一 工具栏
        toolbarIndex = GUI.Toolbar(barPos, toolbarIndex, toolbars);
        switch (toolbarIndex)
        {
            case 0:
                GUI.DrawTexture(texturePos, textures[0]);     
                break;
            case 1:
                GUI.DrawTexture(texturePos, textures[1]);
                break;
            case 2:
                GUI.DrawTexture(texturePos, textures[2]);
                break;
        }
        #endregion

        #region 知识二 选择网格
        //相对toolbar多了一个参数 xCount代表 水平方向最多显示的按钮数量
        selGridIndex = GUI.SelectionGrid(gridPos, selGridIndex, toolbars, 1);
        switch (selGridIndex)
        {
            case 0:
                GUI.DrawTexture(gridTexturePos, textures[0]);
                break;
            case 1:
                GUI.DrawTexture(gridTexturePos, textures[1]);
                break;
            case 2:
                GUI.DrawTexture(gridTexturePos, textures[2]);
                break;
        }
        #endregion
    }
}
